package com.halden.mycache.support.EvictStrategy.impl;

import com.halden.mycache.core.Impl.CacheValue;
import com.halden.mycache.core.Impl.MyCache;
import com.halden.mycache.support.EvictStrategy.ICacheEvictContext;

/**
 * @Author: halden
 * @Data:2023/2/3 10:52
 * @Description: 用于内存淘汰的缓存上下文实现
 * @since 0.0.1
 */
public class CacheEvictContext<K,V> implements ICacheEvictContext<K,V> {

    private K key;

    private MyCache<K,V> cache;

    private CacheValue<V> value;

    public CacheEvictContext(K key, MyCache cache){
        this.key = key;
        this.cache = cache;
    }

    public CacheEvictContext(K key, V value, MyCache cache){
        this.key = key;
        this.value = new CacheValue<>(value);
        this.cache = cache;
    }

    public CacheEvictContext(K key, CacheValue<V> value, MyCache cache){
        this.key = key;
        this.value = value;
        this.cache = cache;
    }

    public CacheEvictContext(MyCache cache){
        this.cache = cache;
    }

    public CacheEvictContext(CacheValue<V> value){
        this.value = value;
    }

    public K getKey() {
        return this.key;
    }

    public MyCache<K, V> getCache() {
        return this.cache;
    }

    public CacheValue<V> getValue() {
        return this.value;
    }

}
